<%layout("/common/_layout.html"){ %>
<script type="text/javascript">

function changeStatus(url,id,targetStatus) {
    
    $.ajax({
        url : url,
        data : {"id":id,"target_status":targetStatus},
        dataType : "json",
        async : true,
        success : function(data) {
        	//parent.swal({title: "配置成功!", text: data.message, type: "success",timer: 2000,   showConfirmButton: false});
        	parent.layer.msg("配置成功: " + data.message);
        }
        
    });
    
}
 
$(function(){
    var $mycheckbox = $('.switch-button').find("input[type='checkbox']");
    $mycheckbox.each(function(){
        var myid = $(this).attr("id");
        $("#"+myid).on({
            'switchChange.bootstrapSwitch': function(event, state) {
              var id =$(this).attr("id") ;
              console.log("switch:"+id+":"+state);
              changeStatus("${base}/memberWhite/changeStatus",id,state?1:0);
            }
        });
    });

  });
  
 
</script>
  <%#ajax userTable:{%>
  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">系统管理</strong> / <small>白名单管理</small></div>
  </div>
  
  <div class="am-g">
  <div class="am-u-sm-12">
  
  <form class="am-form" id="list-form" action="${base}/memberWhite/list" method="post">
  <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
   <div class="am-g">
   <div class="am-u-sm-12 am-u-md-6" style="padding:0px 1.6rem 1.6rem 1rem;margin:0px;">
     <div class="am-btn-toolbar"  style="padding-left:.5rem;">
       <div class="am-btn-group am-btn-group-xs" >
           <%if(so.hasPermission("MEMBER_WHITE_IMPORT")) {%>
            <div class="am-btn-group am-btn-group-xs am-form-file"><button type="button" id="bt_import" class="am-btn am-btn-default"><span class="am-icon-archive"></span> 导入白名单</button> <input id="doc-form-file" type="file" name="import" onChange="ajaxUploadFile('doc-form-file','${base}/memberWhite/upload')" multiple></div>
           <%}%>
            <button type="button" class="am-btn am-btn-default am-btn-xs am-dropdown-toggle" data-am-dropdown-toggle  onClick="location.href='${base}/memberWhite/template'"><span class="am-icon-download"></span> 模板</button> 
            
           <%if(so.hasPermission("MEMBER_WHITE_DEL")) {%>
            <button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default" onclick="deleteAll('${base}/memberWhite/delete')"><span class="am-icon-trash-o"></span> 删除</button>
            <%}%>         
       </div>
     </div>
   </div>
   <div class="am-u-sm-12 am-u-md-3" >
     <div class="am-input-group am-input-group-sm">
       <input type="text" class="am-form-field" id="username" value="${username!}" placeholder="按账号搜索"/>
       <span class="am-input-group-btn">
         <button id="submit-btn" class="am-btn am-btn-default" type="button">搜索</button>
       </span>
     </div>
   </div>
 </div>
 </form>
 </div>
</div>
 
<div class= "am-u-sm-12">
<span  style="color: red;">* 模板中，白名单账号为模拟账号，中移账号为模拟对象，均为手机号，切勿填反；删除仅删除白名单关系表</span>
</div>

<div class="am-g">
     <div class="am-u-sm-12">
        <div class="am-scrollable-horizontal">
         <table class="am-table am-table-striped am-table-hover table-main">
             <thead>
                  <tr class="am-text-nowrap">
                     <th class="table-check"><input type="checkbox"  id="allCheck"/></th>
                     <th class="table-title">白名单账号</th>
                     <th class="table-title">白名单使用者</th>
                     <th class="table-title">中移账号</th>
                     <th class="table-title">工号</th>
                     <th class="table-title">身份</th>
                     <th class="table-title">所属店铺</th>
                     <th class="table-title">操作</th>
                 </tr>
             </thead>
          <tbody>
             <%for(list in pager.list!){%>
                <tr>
                 <td><input type="checkbox" name="ids" value="${list.id}"></td>
                 <td>${list.username}</td>
                  <td>${list.name}</td>
                  <td>${list.cmcc_user}</td>
                  <td>${list.emp_code}</td>
                  <td>
                    <%if (list.member_type==1){%>
                                                                       店长
                    <%}else{%>
                                                                      店员
                    <%}%>
                  </td>
                  <td><a href="${base!}/organization/preview?NumCode=${list.org_num_code}">${list.org_name}</a></td>
                  <td class="switch-button" >
                  <input id="${list.id}"  type="checkbox" data-size='xs' data-am-switch  data-off-text="已禁用" data-on-text="已启用"  
                  <%if (list.enabled==1){%>
                            checked
                  <%}else{%>
                   
                  <%}%>
                  >
                  </td>         
               </tr>
             <%}%> 
          </tbody>
       </table>
       </div>
       
       <div class="am-cf">
         <!-- 分页 -->
         <%if (pager.list.~size > 0){%>
             <div class="am-fr">
                 <% include("/admin/common_pager.tpl"){}%>
             </div>
         <%}else{%>
             <div class="am-kai">
               <h3>没有找到任何记录!</h3>
             </div>
         <%}%>
      </div>
       
  
      </div>
  </div>
 

 
 <div class="am-modal am-modal-no-btn" tabindex="-1" id="modal">
    <div class="am-modal-dialog">
      <div class="am-modal-hd">
        <i class="am-icon-refresh am-icon-spin"></i>
        <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
      </div>
      <div class="am-modal-bd">
        正在处理，请稍等...
      </div>
    </div>
  </div>
 

  <script type="text/javascript">
    $(function(){
      var keywordsObj = {};
      $("#submit-btn").on("click",function(){
        
        if($("#username").val())
          keywordsObj.username = $("#username").val();
    
        var keywords = "";
        if(!$.isEmptyObject(keywordsObj)){
          keywords = JSON.stringify(keywordsObj);
        }
        console.log("keywords = "+ keywords);

        $("#keywords").val(keywords);
        $("#list-form").submit();
      });
    });
 
  </script>
<%}%>
<%}%> 



